/**
 * Created by liubin on 2014/11/26.
 */
define(['user/module'], function (module) {

    'use strict';

    return module.registerFactory('UserList', function($resource, BaseService){
        var res = $resource('api/user',{},
            {
                get: {
                    method: 'get',
                    params: {}
                },
                post: {method: 'post'}
            }
        );
        var listSev = {};
        angular.forEach(['get', 'post'], function (value, key) {
            this[value] = function (args, posts, successFunc, failureFunc, errorFunc) {
                BaseService.process(res, value, args, posts, successFunc, failureFunc, errorFunc);
            }
        }, listSev);
        return listSev;
    }).registerFactory('User', function($resource, BaseService){
        var res = $resource('api/user/:id',
            {
                id: '@id'
            },
            {
                get: {method: 'get'},
                post: {method: 'post'},
                put: {method: 'put'},
                delete: {method: 'delete'}
            }
        );
        var listSev = {};
        angular.forEach(['get','post','put', 'delete'], function (value, key) {
            this[value] = function (args, posts, successFunc, failureFunc, errorFunc) {
                BaseService.process(res, value, args, posts, successFunc, failureFunc, errorFunc);
            }
        }, listSev);
        return listSev;
    }).registerFactory('UserPwd', function($resource, BaseService){
        var res = $resource('api/user/:id/changePwd',
            {
                id: '@id'
            },
            {
                post: {method: 'post'}
            }
        );
        var listSev = {};
        angular.forEach(['post'], function (value, key) {
            this[value] = function (args, posts, successFunc, failureFunc, errorFunc) {
                BaseService.process(res, value, args, posts, successFunc, failureFunc, errorFunc);
            }
        }, listSev);
        return listSev;
    });
});